<!DOCTYPE html PUBLIC "">
<html xmlns="">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">

    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta charset="utf-8">
    <title>关键字回复</title>

    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">

 <!--    <script>
      (function () {
        if (window !== window.top) {
          window.top.location.href = 'http://www.818tu.com';
        }
      })();
    </script> -->

    <!-- bootstrap & fontawesome -->








    <!-- page specific plugin styles -->
    <script src="__PUBLIC__/admin/js/jquery.min.js"></script>
    <script src="__PUBLIC__/admin/js/lodash.min.js"></script>
    <script src="__PUBLIC__/admin/js/moment.min.js"></script>
    <script src="__PUBLIC__/admin/js/zh-cn.js"></script>
    <script src="__PUBLIC__/admin/js/numeral.min.js"></script>
    <script src="__PUBLIC__/admin/js/toastr.min.js"></script>
    <script src="__PUBLIC__/admin/js/cookies.js"></script>
    <script src="__PUBLIC__/admin/js/knockout-min.js"></script>
    <script src="__PUBLIC__/admin/js/knockout.mapping.min.js"></script>
    <script src="__PUBLIC__/admin/js/bootstrap-datetimepicker.min.js"></script>
    <script src="__PUBLIC__/admin/js/jquery.validate.min.js"></script>
    <script src="__PUBLIC__/admin/js/jquery.validate.unobtrusive.min.js"></script>
    <script src="__PUBLIC__/admin/js/clipboard.min.js"></script>
    <script src="__PUBLIC__/admin/js/select2.min.js"></script>
    <script src="__PUBLIC__/admin/js/zh-cn_001.js"></script>
    <script src="__PUBLIC__/admin/js/admin.js"></script>
    <script>
      moment.locale('zh-cn');

      toastr.options.positionClass = 'toast-bottom-right';

      $.fn.select2.defaults.set('language', 'zh-CN');
    </script>

    <!-- text fonts -->


    <!-- ace styles -->


    <!--[if lte IE 9]>
        <link rel="stylesheet" href="https://novel.818tu.com/static/assets/css/ace-part2.min.css" />
    <![endif]-->




    <!--[if lte IE 9]>
        <link rel="stylesheet" href="https://novel.818tu.com/static/css/ace-ie.min.css" />
    <![endif]-->



    <!-- inline styles related to this page -->

    <!-- ace settings handler -->
    <script src="__PUBLIC__/admin/js/ace-extra.min.js"></script>

    <!-- <script>
      var __BASEURL = "https://novel.818tu.com/";
    </script> -->
<link rel="stylesheet" type="text/css" href="__PUBLIC__/admin/css/glyphicons-halflings-regular.css">
<link media="all" href="__PUBLIC__/admin/css/index16.css" type="text/css" rel="stylesheet">
</head>
<body class="no-skin modal-open" style="padding-right: 17px;">

    <!-- #section:basics/navbar.layout -->
    <include file="./Public/gong/title.html" />

    <div class="main-container" id="main-container">
      <script type="text/javascript">
        try{ace.settings.check('main-container' , 'fixed')}catch(e){}
      </script>

      <div id="sidebar" class="sidebar responsive">
          <script type="text/javascript">
            try{ace.settings.check('sidebar' , 'fixed')}catch(e){}
          </script>

<include file="./Public/gong/list.html" />
          <div class="sidebar-toggle sidebar-collapse" id="sidebar-collapse">
            <i class="ace-icon fa fa-angle-double-left" data-icon1="ace-icon fa fa-angle-double-left" data-icon2="ace-icon fa fa-angle-double-right"></i>
          </div>

          <script type="text/javascript">
            try{ace.settings.check('sidebar' , 'collapsed')}catch(e){}
          </script>
      </div>

      <!-- /section:basics/sidebar -->
      <div class="main-content">

                    <!-- <div id="invalid-mp-settings-hint" style="display: none; border-top: 0px none; border-left: 0px none; border-right: 0px none; margin: 0px;" class="alert alert-warning">
    <i class="fa fa-warning"></i> 您的公众号配置不完整，推广前请务必配置好公众号信息。<a href="https://novel.818tu.com/backend/settings/mp">立即配置</a>
</div> -->


        <div class="breadcrumbs" id="breadcrumbs">
          <script type="text/javascript">
            try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
          </script>

          <ul class="breadcrumb">
            <li>
              <i class="ace-icon fa fa-home home-icon"></i>
              <a href="__APP__/Admin/Index/index.html">Home</a>
            </li>
            <li class="active">关键字回复</li>
          </ul><!-- /.breadcrumb -->

          <!-- /section:basics/content.searchbox -->
        </div>

        <!-- /section:basics/content.breadcrumbs -->
        <div class="page-content">
          <div class="page-content-area">
            <div class="row">
              <div class="col-xs-12">
                <!-- PAGE CONTENT BEGINS -->

                <!--/span-->
                <!-- left menu ends -->




<div class="actions-bar">
    <button type="button" class="btn btn-primary" data-toggle="add-keyword"><i class="fa fa-plus"></i> 添加关键字</button>
</div>

<table class="table table-bordered table-stripped">
    <thead>
    <tr>
        <th>关键字</th>
        <th>小说/章节</th>
        <th class="text-right">
            点击
        </th>
        <!-- <td class="text-right">
            新增用户
        </td>
        <td class="text-right">
            新增关注
        </td> -->
        <td class="text-right">
            充值金额
        </td>
        <th class="text-center">操作</th>
    </tr>
    </thead>
    <tbody>
        <volist name="keywords" id="vk">
            <tr class="data-item" data-referral-link-id="196087">
                <td>
                    <span class="keyword">{$vk.keyword}</span>
                </td>
                <td>
                    {$vk.title}                     <div style="margin-top: 5px;" class="text-muted">
                    第{$vk.number}章  {$vk.title2}
                    </div>
                </td>
                <td class="text-right">
                    <span class="counter-field" data-field="clicks">{$vk.clicknum}</span>
                </td>
                <!-- <td class="text-right">
                    <span class="counter-field" data-field="member_count">0</span>
                </td>
                <td class="text-right">
                    <span class="counter-field" data-field="subscribe_count">0</span>
                    <div class="text-muted subscribe-rate-container" style="display: none; font-size: 12px; margin-top: 5px;">
                        关注率 <span class="counter-field" data-field="subscribe_rate">0</span>%
                    </div>
                </td> -->
                <td class="text-right">
                    {$vk.paynum}
                </td>
                <td class="text-center">
                    <a class="btn btn-xs btn-success" href="__URL__/del_reply_keywords?id={$vk.id}"><i class="fa fa-list"></i> 删除</a>
                    <!-- <div class="btn-group">
                        <button type="button" class="btn btn-xs btn-success dropdown-toggle" data-toggle="dropdown">
                            更多 <span class="caret"></span>
                        </button>
                        <ul class="dropdown-menu dropdown-menu-right">
                            <li>
                                <a href="#" data-toggle="delete-keyword" data-id="941"><i class="fa fa-trash-o"></i> 删除</a>
                            </li>
                        </ul>
                    </div> -->
                </td>
            </tr>
        </volist>
                </tbody>
</table>


<div  id="edit-keyword" style="display:none;position: fixed;top: 0px;right: 0px;bottom: 0px;left: 0px;z-index: 1050;display: none;overflow: hidden;outline: 0px none;">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-bind="click: close" aria-label="Close"><span aria-hidden="true">×</span></button>
                <h4 class="modal-title">关键字设置</h4>
            </div>
            <div class="modal-body">
                <form class="form-horizontal" novalidate="novalidate" method="POST" action="__URL__/add_reply_keywords">
                    <div class="form-group">
                        <label class="control-label col-sm-3">关键字</label>
                        <div class="col-sm-7">
                            <input type="text" class="form-control" name="keyword" data-bind="value: keyword" maxlength="20" data-val="true" data-val-required="请输入关键字">
                            <div class="help-block col-sm-10 no-padding-left" data-valmsg-for="keyword" data-valmsg-replace="true"></div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-sm-3">小说</label>
                        <div class="col-sm-7">
                            <select name="bid" style="width:100%"  data-val="true" data-val-required="请选择小说"  aria-hidden="true" id="s1" autocomplete="off">
                                <option value="">--请选择--</option>
                                <volist name="book" id="vb">
                                    <option value="{$vb.id}">{$vb.title}</option>
                                </volist>
                            </select>

                            <div class="help-block col-sm-10 no-padding-left" data-valmsg-for="novel_id" data-valmsg-replace="true"></div>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label col-sm-3">章节</label>
                        <div class="col-sm-7">
                            <select name="biid" style="width:100%"  data-val="true" data-val-required="请选择章节"  aria-hidden="true" id="s2">

                            </select>

                            <div class="help-block col-sm-10 no-padding-left" data-valmsg-for="novel_id" data-valmsg-replace="true"></div>
                        </div>
                    </div>


            </div>
            <div class="modal-footer">
                <button type="submit" class="btn btn-primary">提交</button>
            </div>
            </form>
        </div>
    </div>
</div>
<script >
    $(function(){
            $(".btn-primary").click(function(){
                $("#edit-keyword").css({'display':'block'});
                $(".modal-backdrop").css({'display':'block'});
            });
            $(".close").click(function(){
                $("#edit-keyword").css({'display':'none'});
                $(".modal-backdrop").css({'display':'none'});
            });
    });
</script>
<script type="text/javascript">
$('#s1').change(function(event) {
    var $bid = $(this).val();
    $('#s2').empty();
    $.get('__URL__/selectbookinfo',{'bid':$bid},function(data) {
        $('#s2').append('<option value="">--请选择--</option>')
        if(data != 'error')
        {
            $.each(data, function(key, val) {
                $('#s2').append('<option value="'+val.id+'">[第'+val.number+'章]'+ val.title2+'</option>');
            });
        }
    });
});
</script>
<!-- <script>
    var EditKeywordModal = function () {
        var self = this;
        var defer = null;
        var $modal = null;
        var model = {
            submitting: ko.observable(false),

            keyword: ko.observable(),
            novel_id: ko.observable(),
            article_id: ko.observable(),

            novel_select2_options: {
                minimumInputLength: 0,
                ajax: {
                    url: '/backend/novels/api_search',
                    cache: true,
                    delay: 500,
                    dataType: 'json',
                    data: function (params) {
                        return {
                            q: params.term,
                            page: params.page,
                            per_page: 20
                        }
                    },
                    processResults: select2ProcessResults
                }
            },

            article_select2_options: {
                minimumInputLength: 0,
                ajax: {
                    url: '/backend/articles/api_search',
                    cache: true,
                    delay: 500,
                    dataType: 'json',
                    data: function (params) {
                        return {
                            novel_id: model.novel_id(),
                            q: params.term,
                            page: params.page,
                            per_page: 20
                        }
                    },
                    processResults: select2ProcessResults
                }
            },

            submit: function () {
                self.submit();
            },

            close: function () {
                self.close();
            }
        };

        self.open = function () {
            if (!$modal) {
                $modal = $('#edit-keyword-modal');
                ko.applyBindings(model, $modal.find('.modal-content')[0]);

                model.novel_id.subscribe(function () {
                    model.article_id(null);
                });
            }

            $modal.modal('show');

            defer = $.Deferred();

            return defer.promise();
        };

        self.submit = function () {
            if (model.submitting() || !$modal.find('form').valid()) {
                return false;
            }

            model.submitting(true);

            var data = {
                keyword: model.keyword().trim(),
                novel_id: model.novel_id(),
                article_id: model.article_id()
            };

            $.ajax({
                url: '/backend/wx_reply/api_create_keyword',
                type: 'POST',
                contentType: 'application/json',
                data: JSON.stringify(data)
            })
                .then(function () {
                    self.close();
                    defer.resolve();
                })
                .fail(handleAjaxError)
                .always(function () {
                    model.submitting(false);
                });
        };

        self.close = function () {
            $modal.modal('hide');
        };

        function select2ProcessResults(data, params) {
            params.page = params.page || 1;

            return {
                results: _.map(data, function (it) {
                    return { id: it.id, text: it.title }
                }),
                pagination: {
                    more: data.length === 20
                }
            };
        }
    };

    EditKeywordModal.instance = new EditKeywordModal();
</script>
<script>
    $(function () {
        $('[data-toggle="add-keyword"]').click(function () {
            EditKeywordModal.instance
                .open()
                .then(function () {
                    reloadPage(500);
                });

            return false;
        });

        $('[data-toggle="delete-keyword"]').click(function () {
            var id = $(this).data('id');
            var keyword = $(this).closest('tr').find('.keyword').text().trim();

            Modal
                .confirm({
                    title: '删除关键字',
                    message: '确定要删除关键字 "' + keyword + '" 吗?'
                })
                .then(function () {
                    deleteKeyword(id);
                });

            return false;
        });

        $('.data-item').each(function () {
            loadCounter($(this).data('referral-link-id'));
        });

        function loadCounter(id) {
            return $.get('/backend/referral_links/api_get_counter/' + id, function (counter) {
                var $row = $('.data-item[data-referral-link-id="' + id + '"]');
                $row.find('.counter-field').each(function () {
                    var field = $(this).data('field');

                    if (field === 'subscribe_rate') {
                        $(this).html(Math.round(counter[field] * 100));
                    } else {
                        $(this).html(counter[field]);
                    }
                });

                if (counter.subscribe_rate > 0) {
                    $row.find('.subscribe-rate-container').show();
                }
            });
        }

        function deleteKeyword(id) {
            return $.ajax({
                url: '/backend/wx_reply/api_delete_keyword/' + id,
                type: 'POST',
                contentType: 'application/json'
            })
            .then(function () {
                toastr.success('删除成功');
                reloadPage(500);
            })
            .fail(handleAjaxError);
        }
    });
</script> -->

                                <!-- PAGE CONTENT ENDS -->
                            </div><!-- /.col -->
                        </div><!-- /.row -->
                    </div><!-- /.page-content-area -->
                </div><!-- /.page-content -->
            </div><!-- /.main-content -->

        </div><!-- /.main-container -->

        <!-- basic scripts -->

        <!-- <script type="text/javascript">
            if('ontouchstart' in document.documentElement) document.write("<script src='https://novel.818tu.com/static/assets/js/jquery.mobile.custom.min.js'>"+"<"+"/script>");
        </script> -->
        <script src="__PUBLIC__/admin/js/bootstrap.min.js"></script>
        <script src="__PUBLIC__/admin/js/jquery.webui-popover.min.js"></script>
        <script src="__PUBLIC__/admin/js/jquery.ui.widget.min.js"></script>
        <script src="__PUBLIC__/admin/js/jquery.fileupload.min.js"></script>

        <!-- page specific plugin scripts -->

        <!-- ace scripts -->
        <script src="__PUBLIC__/admin/js/ace-elements.min.js"></script>
        <script src="__PUBLIC__/admin/js/ace.min.js"></script>

        <!-- inline scripts related to this page -->

        <!-- the following scripts are used in demo only for onpage help and you don't need them -->


        <!-- <script type="text/javascript"> ace.vars['base'] = 'https://novel.818tu.com/static'; </script> -->
        <script src="__PUBLIC__/admin/js/elements.onpage-help.js"></script>
        <script src="__PUBLIC__/admin/js/ace.onpage-help.js"></script>


<div class="modal-backdrop fade in" style="display:none;background:rgba(0,0,0)"></div>
</body>
</html>
